﻿using System.Web.Security;
using AspAuthentication.Interfaces;

namespace AspAuthentication.Providers
{
    /// <summary>
    /// Defines the class FormsAuthenticationProvider
    /// </summary>
    public class FormsAuthenticationProvider : IFormsAuthenticationProvider
    {
        /// <summary>
        /// Signs the out.
        /// </summary>
        public void SignOut()
        {
            FormsAuthentication.SignOut();
        }

        /// <summary>
        /// Sets the auth cookie.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="createPersistentCookie">if set to <c>true</c> [create persistent cookie].</param>
        public void SetAuthCookie(string userName, bool createPersistentCookie)
        {
            FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
        }

        /// <summary>
        /// Hashes the password for storing in config file.
        /// </summary>
        /// <param name="password">The password.</param>
        /// <param name="formsAuthPasswordFormat">The forms auth password format.</param>
        /// <returns></returns>
        public string HashPasswordForStoringInConfigFile(string password, string formsAuthPasswordFormat)
        {
            return FormsAuthentication.HashPasswordForStoringInConfigFile(password, formsAuthPasswordFormat);
        }
    }
}